/* 
 * File:   v4l2_interface.h
 * Author: gustavo
 *
 * Created on May 19, 2011, 3:28 AM
 */

#ifndef V4L2_DRIVER_H
#define	V4L2_DRIVER_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <linux/videodev2.h>

#include "v4l.h"

	/* = Getters ================================================================ */
	int v4l2_driver_get_capability(int fd, struct v4l2_capability * vc);
	int v4l2_driver_queryctrl(int fd, struct v4l2_queryctrl *qc);
	int v4l2_driver_querymenu(int fd, struct v4l2_querymenu *qm);
	int v4l2_driver_get_cropcap(int fd, struct v4l2_cropcap * cropcap);
	int v4l2_driver_get_standard_id(int fd, v4l2_std_id * std_id);
	int v4l2_driver_get_standard(int fd, struct v4l2_standard * standard);
	int v4l2_driver_get_format(int fd, struct v4l2_format * fmt, enum v4l2_buf_type type);
	int v4l2_driver_get_input(int fd, struct v4l2_input * input);
	int v4l2_driver_get_interval(int fd, struct v4l2_fract * interval);

	int v4l2_driver_get_ctrl(int fd, struct v4l2_control * ctrl);
	/* = Setters ================================================================ */
	int v4l2_driver_set_standard(int fd, v4l2_std_id * std_id);
	int v4l2_driver_set_standard_id(int fd, v4l2_std_id * std_id);
	int v4l2_driver_set_format(int fd, struct v4l2_format * fmt);
	int v4l2_driver_set_fps(int fd, int fps);
	int v4l2_driver_set_crop(int fd, struct v4l2_crop * crop);
	int v4l2_driver_set_input(int fd, int * input);
	int v4l2_driver_set_interval(int fd, struct v4l2_fract * interval);

	int v4l2_driver_set_ctrl(int fd, struct v4l2_control * ctrl);

	/* = Enumerations =========================================================== */
	int v4l2_driver_enum_input(int fd, struct v4l2_input * input, int init, int index);
	int v4l2_driver_enum_output(int fd, struct v4l2_output * output, int init, int index);
	int v4l2_driver_enum_audio(int fd, struct v4l2_audio * audio, int init, int index);
	int v4l2_driver_enum_audioout(int fd, struct v4l2_audioout * audioout, int init, int index);
	int v4l2_driver_enum_standard(int fd, struct v4l2_standard * standard, int init, int index);
	int v4l2_driver_enum_fmtdesc(int fd, struct v4l2_fmtdesc * fmtdesc, int init, int index, enum v4l2_buf_type type);
	int v4l2_driver_enum_frmsize(int fd, struct v4l2_frmsizeenum * frmsize, int init, int pixel_format, int index);
	int v4l2_driver_enum_frminterval(int fd, struct v4l2_frmivalenum * frminterval, int init, int pixel_format, int w, int h, int index);

	/* = Others ================================================================= */
	int v4l2_driver_request_buffers(int fd, struct v4l2_requestbuffers * req_buff);
	int v4l2_driver_query_buffer(int fd, struct v4l2_buffer * query_buff);
	int v4l2_driver_enqueue_buffer(int fd, struct v4l2_buffer * queue_buff);
	int v4l2_driver_dequeue_buffer(int fd, struct v4l2_buffer * queue_buff);
	int v4l2_driver_streamon(int fd, enum v4l2_buf_type type);
	int v4l2_driver_streamoff(int fd, enum v4l2_buf_type type);

	/* = Get lists ============================================================== */
	List * v4l2_driver_get_frame_size_list(int fd);
	List * v4l2_driver_get_frame_intervals_list(int fd);
	List * v4l2_driver_get_frame_size_list_test(int fd);
	List * v4l2_driver_get_pixel_format_list(int fd);
	List * v4l2_driver_get_input_list(int fd);
	List * v4l2_driver_get_standard_list(int fd);
	List * v4l2_driver_get_ctrl_list(int fd);
	/* =  ============================================================== */

	/* = Capabilities =========================================================== */
	int v4l2_driver_cap_request_buffers_mmap(int fd, struct v4l2_requestbuffers *req_buff, int nbuffers);
	int v4l2_driver_cap_request_buffers_user(int fd, struct v4l2_requestbuffers * reqbuf, int count, enum v4l2_buf_type type);
	int v4l2_driver_cap_dequeue_buffer_mmap(int fd, struct v4l2_buffer * buf, int * again);
	int v4l2_driver_cap_dequeue_buffer_user(int fd, struct v4l2_buffer * buf, int * again);
	int v4l2_driver_cap_enqueue_buffer_mmap(int fd, int index);
	int v4l2_driver_cap_enqueue_buffer_user(int fd, int index, void * ptr, int length);

	/*===============================================*/

	int v4l2_driver_mmap(int fd, struct v4l_buffers * v4lbuffers, struct v4l2_requestbuffers *reqbuf);
	int v4l2_driver_mmap_old(int fd, int nbuffers, struct v4l_buffers * v4lbuffers);
	int v4l2_driver_enqueue_buff_x(int fd, enum v4l2_buf_type buf_type, int x);
	int v4l2_driver_start(int fd, enum v4l2_buf_type buf_type);
	int v4l2_driver_stop(int fd, enum v4l2_buf_type type);
	int v4l2_driver_unmap(struct v4l_buffers * v4lbuffers);



#ifdef	__cplusplus
}
#endif

#endif	/* V4L2_DRIVER_H */

